package com.zzjson.mongodb.morphia;

import com.mongodb.MongoClient;
import org.mongodb.morphia.Datastore;
import org.mongodb.morphia.Morphia;
import org.mongodb.morphia.query.Query;

/**
 * <p>****************************************************************************</p>
 * <p><b>Copyright © 2010-2019 shuncom team All Rights Reserved<b></p>
 * <ul style="margin:15px;">
 * <li>Description : cn.zzjson.mongodb.morphia</li>
 * <li>Version     : 1.0.0</li>
 * <li>Creation    : 2019年04月02日</li>
 * <li>@author     : zzy0_0</li>
 * </ul>
 * <p>****************************************************************************</p>
 */
public class MorphiaTest {
    public static void main(String[] args) {
        Morphia morphia = new Morphia();
        Datastore datastore = morphia.createDatastore(new MongoClient("127.0.0.1", 27017), "myNewCollection1");
        //Hotel hotel = new Hotel();
        //hotel.setHotelName("麓谷酒店");
        //hotel.setHotelAddress("湖南长沙高新区麓谷企业广场");
        //
        //Key<Hotel> key = datastore.save(hotel);
        //
        //System.out.println(key.toString());

        Query<Hotel> query = datastore.createQuery(Hotel.class);

        System.out.println(query.get());
    }
}